<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "user".
 *
 * @property int $user_id
 * @property string $username
 * @property string $pwd
 * @property string $tel
 * @property string $email
 */
class Users extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
//            [['username', 'email'], 'string', 'max' => 30],
//            [['pwd'], 'string', 'max' => 32],
            [['tel'], 'string', 'max' => 11],
            [['tel'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
//            'user_id' => 'User ID',
//            'username' => 'Username',
//            'pwd' => 'Pwd',
            'tel' => 'Tel',
//            'email' => 'Email',
        ];
    }
    public function findData($data){
        //连库
        $connection = \Yii::$app->db;
//        $secondaryConnection = \Yii::$app->secondDb;
        //查询语句
        $command = $connection->createCommand("SELECT * FROM user where tel='$data[tel]'");
        //执行
        $posts = $command->queryAll();
        //返回
        return $posts;


    }
}
